/*
 * @Author: 付小清
 * @Date: 2020-11-30 10:48:49
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-04-22 15:55:26
 * @Description: 系统设置接口
 */
import request from '@/utils/request'

// =======================角色菜单权限=======================

// 菜单树形图
export function menuTree(query) {
  return request({
    url: '/sys/platform/menu/tree',
    method: 'get',
    params: query
  })
}

// 角色菜单权限列表
export function permissionRole(query) {
  return request({
    url: '/sys/platform/permission/role',
    method: 'get',
    params: query
  })
}

// 根据角色id返回菜单权限ID
export function roleMenu(query) {
  return request({
    url: '/sys/platform/permission/role/menu/id/' + query.roleId,
    method: 'get'
    // params: query
  })
}

// 设置角色菜单
export function setRoleMenu(query) {
  return request({
    url: '/sys/platform/permission/role',
    method: 'PUT',
    data: query
  })
}

// =======================角色管理=======================

// 查询所有角色
export function roleAll(query) {
  return request({
    url: '/sys/platform/role/all',
    method: 'get',
    params: query
  })
}

// 删除角色
export function roleDelete(query) {
  return request({
    url: '/sys/platform/role/' + query.roleId,
    method: 'delete'
    // params: query
  })
}

// 编辑角色
export function roleUpdate(query) {
  return request({
    url: '/sys/platform/role',
    method: 'put',
    data: query
  })
}

// 添加角色
export function roleAppend(query) {
  return request({
    url: '/sys/platform/role',
    method: 'post',
    data: query
  })
}

// =======================员工权限=======================

// 员工权限=》员工列表
export function permissionEmp(query) {
  return request({
    url: '/sys/platform/permission/emp',
    method: 'get',
    params: query
  })
}

// 员工权限=》员工角色
export function permissionEmpRole(query) {
  return request({
    url: '/sys/platform/permission/emp/role/' + query.empIds,
    method: 'get'
    // params: query
  })
}

// 分配所选员工角色
export function empRoleAssignment(query) {
  return request({
    url: '/sys/platform/permission/emp/role',
    method: 'post',
    data: query
  })
}

// 删除所选员工角色
export function deleteEmpRole(query) {
  return request({
    url: '/sys/platform/permission/emp/role/del',
    method: 'post',
    data: query
  })
}

// =======================员工设置=======================

// 员工列表
export function empAll(query) {
  return request({
    url: '/sys/platform/emp/all',
    method: 'get',
    params: query
  })
}

// 员工添加
export function empAppend(query, config) {
  return request({
    url: '/sys/platform/emp',
    method: 'post',
    data: query,
    ...config
  })
}

// 员工编辑
export function empUpdate(query, config) {
  // console.log(config);
  // return;
  return request({
    url: '/sys/platform/emp',
    method: 'put',
    data: query,
    ...config
  })
}

// 员工冻结/解冻
export function empFreeze(query) {
  return request({
    url: `/sys/platform/emp/freeze/${query.userId}/${query.state}`,
    method: 'get'
    // params: query
  })
}

// 员工重置
export function empRes(query) {
  return request({
    url: `/sys/platform/emp/res/${query.userId}`,
    method: 'get'
    // params: query
  })
}

// 员工详情
export function empDetail(query) {
  return request({
    url: `/sys/platform/emp/${query.userId}`,
    method: 'get'
    // params: query
  })
}

// 员工删除
export function empDelete(query) {
  return request({
    url: `/sys/platform/emp/${query.userId}`,
    method: 'delete'
    
  })
}

// =======================日志管理=======================
export function logRecords(query){
  return request({
    url: '/log/page',
    method: 'get' ,
    params: query
  })
}